/**
 * Created by meiguizhinian on 2018/6/21
 * Copyright © 2018 lixiaolong. All rights reserved.
 */

let LLResourceManager = {
	sharedInstance : function () {
		return this;
	},
	switchSpace : function(space) {
		if (!space || space.length===0 || this._space===space) {
			return;
		}
		if (this._space.length!==0) {
			/*TODO:删除当前路径*/
		} else {
            cc.FileUtils.getInstance().addSearchPath("res/game/"+space);
			cc.FileUtils.getInstance().addSearchPath("res/game/"+space+"/NETDATA");
		}
		this._space = space;

		ivy.UILabelTTF.prototype.setGlobalUseSystemFontEnable(true);
		ivy.UILabelTTF.prototype.setGlobalUseSystemFont(true);
		ivy.SceneCommonDataManager.getInstance().initWithFile("Scene/scene.config");
		ivy.CocosActionDataManager.getInstance().initWithFile("gameaction.bin");
		ivy.CocosActionCreater.getInstance().init();

		let uim = ivy.UIManager.getInstance();
		uim.initUIDataWithFile("UI/uiform.bin");
		uim.initUIControlDataWithFile("UI/uicontrol.bin");

		ivy.registerUIDefaultCreater();
	},
	attach : function(node, name) {
		let uim = ivy.UIManager.getInstance();
		uim.initUISystem(node);
	},

	getImageSize : function(filepath) {
		let size = cc.SizeZero();
		let fullpath = cc.FileUtils.fullPathForFilename(filepath);
		if (cc.sys.isNative) {
			let image = new cc.Image();
			if (image) {
				if (image.initWithImageFile(fullpath)) {
					size.setSize(image.getWidth(), image.getHeight());
				}
				image.release();
			}
		} else {
			let res = cc.loader.getRes("res/HelloWorld.png");
			size = res.getContentSize();
		}
		return size;
	},

	_space : "",
};
